﻿@inject IStringLocalizer<LanguageSelector> L

<MudTooltip Text="@LayoutService.LanguageCode">
    <MudMenu Icon="@Icons.Material.Outlined.Translate" Color="Color.Inherit" Direction="Direction.Bottom" OffsetY="true"
        Dense="true">
        @foreach (var language in LocalizationConstant.SupportedLanguages)
        {
            if (language.Code == LayoutService.LanguageCode)
            {
                <MudMenuItem style="background:var(--mud-palette-primary); color:white">@L[language.DisplayName]</MudMenuItem>
            }
            else
            {
                <MudMenuItem OnClick="(()=> ChangeLanguageAsync(language.Code))">@L[language.DisplayName]</MudMenuItem>
            }
        }
    </MudMenu>
</MudTooltip>

@code {
    private async Task ChangeLanguageAsync(string languageCode)
    {
        await LayoutService.ChangeLanguageAsync(languageCode);
        //NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true);
    }
}